package com.zhala.system.service.impl;

import com.zhala.system.domain.ZlScada;
import com.zhala.system.mapper.ZlScadaMapper;
import com.zhala.system.service.ZlScadaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ZlScadaImpl implements ZlScadaService {
    @Autowired
    private ZlScadaMapper zlScadaMapper;

    @Override
    public int save(ZlScada zlScada) {
        return zlScadaMapper.add(zlScada);
    }

    @Override
    public int saveOrUpdate(ZlScada zlScada) {
        ZlScada existingZlScada =  zlScadaMapper.record();

        System.out.println(zlScada);
        if (existingZlScada == null) {
            return zlScadaMapper.add(zlScada);
        }
        zlScada.setId(existingZlScada.getId());
        return zlScadaMapper.update(zlScada);
    }

    @Override
    public ZlScada getFind() {
        return zlScadaMapper.record();
    }
}
